package meituan;

import java.util.Scanner;

public class one {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String str = scan.next();
        boolean tou = false;
        boolean wei = false;
        int counttou = 0;
        int countwei = 0;
        for (int i = 0; i < str.length(); i++) {
            if(str.charAt(i)=='M'){
                tou = true;
            }
            if(str.charAt(i)=='T'){
                if(tou){
                    counttou = i;
                    break;
                }
            }
        }
        for (int i = str.length()-1; i >=0; i--) {
            if(str.charAt(i)=='T'){
                wei = true;
            }
            if(str.charAt(i)=='M'){
                if(wei){
                    countwei = i;
                    break;
                }
            }
        }
        System.out.println(str.substring(counttou+1, countwei));
    }
}
